package com.easyui.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.easyui.bean.Student;
import com.easyui.common.SelStudent;
import com.easyui.common.SelTeacher;

public class UpdateTeacherServlet extends HttpServlet {
       
    public UpdateTeacherServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
		

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/json;charset=utf-8");
		response.setCharacterEncoding("UTF-8");
		request.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		
		JSONObject jsonAll = null;
		boolean success = false;
		String msg = "";
		
		String tno = request.getParameter("tno");
		String tname = request.getParameter("tname");
		String sex = request.getParameter("sex");
	System.out.println(tno);
	System.out.println(tname);
	System.out.println(sex);
		jsonAll= new JSONObject();
		
		SelTeacher st = new SelTeacher();
		success = st.updateTeacher(tno,tname,sex);
		
		if(success) {
			msg = "修改老师信息成功.";
		} else {
			msg = "修改老师信息失败";
		}
		
		jsonAll.put("success", success);
		jsonAll.put("msg", msg);
		
		out.print(jsonAll);
		out.flush();
		out.close();
	}

}
